package com.woniuxy.mapper.impl;

import com.woniuxy.mapper.EmpDao;
import com.woniuxy.entity.Emp;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.util.List;

/**
 * @author 作者
 * @create 2025-06-17 16:39
 */
public class EmpDaoImpl implements EmpDao {

    QueryRunner queryRunner=new QueryRunner();
    @Override
    public Emp selectByEid(int eid) throws Exception {
        return queryRunner.query(JdbcUtil.getConnection(),
                "select * from emp where eid=?", new BeanHandler<>(Emp.class),eid);
    }

    @Override
    public List<Emp> selectAll() throws Exception {
         return queryRunner.query(JdbcUtil.getConnection(),
                "select * from emp ", new BeanListHandler<>(Emp.class));
    }
}
